package logic

import (
	"context"
	"user_srv/internal/dao"
	"user_srv/internal/svc"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetUnreadCountLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGetUnreadCountLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUnreadCountLogic {
	return &GetUnreadCountLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 获取未读消息数量
func (l *GetUnreadCountLogic) GetUnreadCount(in *user.GetUnreadCountReq) (*user.GetUnreadCountResp, error) {
	count := dao.GetUnreadCount(in.UserId) // 获取未读消息数量
	return &user.GetUnreadCountResp{
		Count: count,
	}, nil
}
